#include "include/Node.hpp"
#include <stdlib.h>

Node::Node(std::initializer_list<double> c, double w)
{
    for(auto iter=c.begin(); iter<c.end(); iter++)
    {
        cord.push_back(*iter);    
    }
    weight = w;
}

std::ostream& operator<<(std::ostream& os, Node n)
{
    os << "Node(" << *(n.cord.begin());
    for(auto iter=n.cord.begin()+1; iter<n.cord.end(); iter++)
    {
        os <<", " <<*iter;
    }
    os << ") with weight= " << n.weight << std::endl;
    return os;
}

double Node::operator[](unsigned int idx)
{
    if(idx >= cord.size())
    {
        std::cerr << "ERROR! Invalid index for Node[" << idx << "]"<< std::endl;
        abort();
    }
    return cord[idx];
}

double Node::get_weight()
{
    return weight;
}
